﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CrmDocman.DataCore;

/// <summary>
/// Summary description for GioiThieuHelper
/// </summary>
public class GioiThieuHelper : TWSData
{
	public GioiThieuHelper()
	{
        m_dao = DataBridge.GetInstance();
	}

    public GioiThieuDataSet LoadGioiThieu()
    {

        GioiThieuDataSet lspDs = new GioiThieuDataSet();
        string sql = m_dao.BuildSelectQuery(lspDs.GioiThieu);

        m_dao.FillDataTable(lspDs.GioiThieu, sql);
        m_dao.Connection.CloseConnection();
        return lspDs;
    }

    public GioiThieuDataSet LoadGioiThieu(int GioiThieuID)
    {

        GioiThieuDataSet lspDs = new GioiThieuDataSet();
        string sql = m_dao.BuildSelectQuery(lspDs.GioiThieu);
        sql += " where ID = " + GioiThieuID;

        m_dao.FillDataTable(lspDs.GioiThieu, sql);
        m_dao.Connection.CloseConnection();
        return lspDs;
    }

    public GioiThieuDataSet LoadGioiThieuViTri(string ViTri)
    {

        GioiThieuDataSet lspDs = new GioiThieuDataSet();
        string sql = m_dao.BuildSelectQuery(lspDs.GioiThieu);
        sql += " where ViTri = '" + ViTri+"'";

        m_dao.FillDataTable(lspDs.GioiThieu, sql);
        m_dao.Connection.CloseConnection();
        return lspDs;
    }

    public bool SaveGioiThieu(GioiThieuDataSet lspDs)
    {
        m_dao.UpdateDataTable(lspDs.GioiThieu);
        m_dao.Connection.CloseConnection();
        return true;

    }

}
